package com.hs.srm.admin.modules.harmfulsubstance.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hs.srm.admin.modules.harmfulsubstance.dao.SvhcItemDao;
import com.hs.srm.admin.modules.harmfulsubstance.entity.SvhcItemEntity;
import com.hs.srm.admin.modules.harmfulsubstance.service.SvhcItemService;
import com.hs.srm.base.common.utils.QueryParam;
import com.hs.srm.common.utils.PageUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * ServiceImpl实现类
 *
 * @author ych
 * @since 2020-03-12 09:11:25
 */
@Service("svhcItemService")
public class SvhcItemServiceImpl extends ServiceImpl<SvhcItemDao, SvhcItemEntity> implements SvhcItemService {

    @Resource
    private SvhcItemDao svhcItemDao;

    /**
     * 列表数据查询
     *
     * @param params
     * @return
     */
    @Override

    public PageUtils queryPage(Map<String, Object> params) {

        //高度关注物质
        String svhc = (String) params.get("svhc");

        //中文名称
        String zhName = (String) params.get("zhName");

        //英文名称
        String enName = (String) params.get("enName");

        //化学文摘号
        String casNo = (String) params.get("casNo");

        Page page = this.selectPage(new QueryParam<SvhcItemEntity>(params).getPage(),
                new EntityWrapper<SvhcItemEntity>()
                        .eq(StringUtils.isNotBlank(svhc), "svhc", svhc)
                        .like(StringUtils.isNotBlank(zhName), "zh_Name", zhName)
                        .like(StringUtils.isNotBlank(enName), "en_Name", enName)
                        .like(StringUtils.isNotBlank(casNo), "cas_No", casNo)
                        .eq("delete_flag", 0)
                        .orderBy("create_date",false)

        );

        return new PageUtils(page);
    }
}